<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="renderer" content="webkit">

    <title></title>
    <link rel="shortcut icon" th:href="@{/images/favicon.ico}"/>
    <link rel="stylesheet" th:href="@{/css/css_x/centro/pintuer.css}">
    <link rel="stylesheet" th:href="@{/css/css_x/centro/admin.css}">
    <script th:src="@{/js/js_x/fondo/jquery.js}"></script>
    <script th:src="@{/js/js_x/reservation/pintuer.js }"></script>
    <style type="text/css">
        .pagelist>span{
            border: none;
        }
    </style>
</head>
<body>
<!--当前admin的id-->
<input type="hidden" id="adminId"  th:value="${adminId}">

<form method="post" action="">
    <div class="panel admin-panel">
        <div class="panel-head"><strong>管理员列表</strong></div>
        <div class="padding border-bottom">
            <ul class="search">
                <li>
                    <a th:href="@{addAdminLink}">
                        <button type="button" class="button border-red">添加</button>
                    </a>
                </li>
            </ul>
        </div>
        <table class="table table-hover text-center">
            <tr>
                <th>ID</th>
                <th>管理员</th>
                <th>姓名</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
            <tr th:each="admin:${adminList}">
                <td th:text="${admin.id}">苏州人</td>
                <td th:text="${admin.adminNumber}">苏州人</td>
              <!--  <td th:text="${admin.password}">苏州人</td>-->
                <td th:text="${admin.name}">苏州人</td>
                <td th:text="${admin.delIdent==0 ? '已启用' : '已禁用'}">苏州人</td>
                <td>
                    <div class="button-group"><a class="button border-red" th:id="${admin.id}" name="banAdmin" th:href="@{/a/u/delete_admin(id = ${admin.id},delIdent = ${admin.delIdent == 1 ? 0 : 1})}" th:text="${admin.delIdent==0 ? '禁用' : '启用'}">禁用</a></div>
                </td>
            </tr>

            <tr>
                <td colspan="8">
                    <div class="pagelist">
                        <a th:href="@{/a/u/admin(currentPage = 1)}">首页</a>
                        <a th:if="${currentPage gt 1}" th:href="@{/a/u/admin(currentPage = ${currentPage - 1})}">上一页</a>
                        <!--<span class="current">1</span>-->
                        <a th:each="page:${#numbers.sequence(1,totalPage)}" th:href="@{/a/u/admin(currentPage = ${page})}" th:text="${page}">1</a>
                        <a th:if="${currentPage lt totalPage}" th:href="@{/a/u/admin(currentPage = ${currentPage + 1})}">下一页</a>
                        <a th:href="@{/a/u/admin(currentPage = ${totalPage})}">尾页</a>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</form>
</body>
<script type="text/javascript">
    $(function () {
        //获取所有name为banAdmin的对象
        var btns = document.getElementsByName("banAdmin");
        var adminId = $("#adminId").val();
        //   alert(adminId)
        for (var i = 0;i<btns.length;i++) {
            var btn = btns[i];
            //将当前dom对象转化为jquery对象
            var $btn  = $(btn) ;
            //获取当前按钮的id名称，如果id=1，则不能被禁用，，如果id=当前账户的id，也不能被禁用
            var btnId = $btn.attr('id');
            //alert(btnId);
            if(btnId == 1 || btnId == adminId){
                //将按钮锁死
                $btn.attr("disabled",true);
            }
        }
    })
</script>
</html>